package com.lanou.zy.projecta.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.zy.projecta.fragment.CountryAllFragment;

import java.util.List;

/**
 * Created by dllo on 15/10/30.
 */
public class CountryViewPagerAdapter extends FragmentPagerAdapter {

    private List<String> datas;

    public CountryViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public void addData(List<String> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

//    public void addDatas(List)


    @Override
    public int getCount() {
//        return Integer.MAX_VALUE;
        return datas != null && datas.size() > 0 ? Integer.MAX_VALUE : 0;
    }


    @Override
    public Fragment getItem(int position) {
        String url = datas.get(position % datas.size());
        return CountryAllFragment.getInstance(url);
    }
//
//    @Override
//    public void destroyItem(ViewGroup container, int position, Object object) {
//        container.removeView((View) object);
//    }

}
